package cn.com.duiba.millionaire.center.biz.remoteservice;

import cn.com.duiba.millionaire.center.api.dto.MillionaireGameDto;
import cn.com.duiba.millionaire.center.api.remoteservice.RemoteMillionaireGameService;
import cn.com.duiba.millionaire.center.biz.entity.MillionaireGameEntity;
import cn.com.duiba.millionaire.center.biz.service.MillionaireGameService;
import cn.com.duiba.wolf.utils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by sunchangji on 2018/3/7.
 */
@RestController
public class RemoteMillionaireGameServiceImpl implements RemoteMillionaireGameService {

    @Autowired
    private MillionaireGameService millionaireGameService;

    @Override
    public boolean gameInsert(MillionaireGameDto millionaireGameDto) {
        return millionaireGameService.gameInsert(BeanUtils.copy(millionaireGameDto, MillionaireGameEntity.class));
    }

    @Override
    public boolean updateById(MillionaireGameDto millionaireGameDto) {
        return millionaireGameService.updateById(BeanUtils.copy(millionaireGameDto, MillionaireGameEntity.class));
    }

    @Override
    public MillionaireGameDto findById(Long id) {
        MillionaireGameEntity entity = millionaireGameService.findById(id);
        return BeanUtils.copy(entity, MillionaireGameDto.class);
    }

    @Override
    public List<MillionaireGameDto> findByBagId(Long bagId) {
        List<MillionaireGameEntity> gameEntities = millionaireGameService.findByBagId(bagId);
        return BeanUtils.copyList(gameEntities,MillionaireGameDto.class);
    }

    @Override
    public boolean deleteById(Long id) {
        return millionaireGameService.deleteById(id);
    }
}
